﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

/** 
 ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
 * Description: 
 * Author: Heller (HellerSong@outlook.com)
 * CreationTime: 3/28/2015 6:23:42 PM
 ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** 
 **/
namespace DevGrammar
{
	[TestClass]
	public class TestMath
	{
		[TestMethod]
		public void test_number_division()
		{
			int value = 17;
			int mod = value % 5;
			int round = value / 5;
			Console.WriteLine("mod is: " + mod);		// Result: 2
			Console.WriteLine("round is: " + round);	// Result: 3
		}

		[TestMethod]
		public void test_decimal_rounding()
		{
			double d1 = 2.34;
			double d2 = 4.46;
			// Decimal half adjustment
			Console.WriteLine(Math.Round(d1, 1));		// Result: 2.3
			Console.WriteLine(Math.Round(d2, 1));		// Result: 4.5

			Console.WriteLine(Math.Ceiling(3.4));   // Result: 4
			Console.WriteLine(Math.Floor(3.4));     // Result: 3
		}

		[TestMethod]
		public void test_square_and_logarithm()
		{
			// Get the square root of the number
			Console.WriteLine(Math.Sqrt(25));		// Result: 5
			Console.WriteLine(Math.Pow(27, 3));  // Result: 3

			// log
			Console.WriteLine(Math.Log(25, 5)); // Result: 2
			Console.WriteLine(Math.Log(27, 5)); // Result: 2.047818

			// round integer
			double i1 = 2.456;
			Console.WriteLine(Math.Round(i1));
		}
	}
}
